﻿using AutoMapper;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartConference.Api.Applocations.IServices;
using SmartConference.Api.DTO;
using SmartConference.Domain;
using SmartConference.ErrorCode;
using SmartConference.Infrastructure.Implements;
using SmartConference.Infrastructure.Interfaces;
using System.ComponentModel;

namespace SmartConference.Api.Controllers
{
    /// <summary>
    /// 会议管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [ApiExplorerSettings(GroupName = "会议管理")]
    public class MeetAppiontController : ControllerBase
    {
        private readonly IMeetingAppointServices meetingAppointServices;

        public MeetAppiontController(IMeetingAppointServices meetingAppointServices)
        {
            this.meetingAppointServices = meetingAppointServices;
        }

        /// <summary>
        /// 会议预约列表
        /// </summary>
        /// <param name="MeetingName">会议名称</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">页容量</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<ApiPaging<MeetAppointDTO>>> MeetAppiontList(string? MeetingName, [DefaultValue(1)] int pageIndex, [DefaultValue(10)] int pageSize)
        {
            try
            {
                return await meetingAppointServices.MeetAppiontList(MeetingName, pageIndex, pageSize);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 会议预约
        /// </summary>
        /// <param name="meetingReservation"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult> AddAppionMent(AddMeetingReservationDTO meetingReservationDTO)
        {
            try
            {
                return await meetingAppointServices.AddAppionMent(meetingReservationDTO);
            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        ///  编辑会议
        /// </summary>
        /// <param name="meetingReservation"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult> UpdateAppionMent(MeetingReservation meetingReservation)
        {
            try
            {
                return await meetingAppointServices.UpdateAppionMent(meetingReservation);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
